package com.zyp.springdemo.handler;

import com.zyp.springdemo.entity.ResultModel;
import com.zyp.springdemo.entity.ResultTools;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
public class GlobalExceptionHandler extends Exception {
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    private ResultModel exceptionHandler(HttpServletRequest req, Exception e){
        return ResultTools.resultError(e.getMessage(),null);
    }

}
